package com.home766.dao.impl;

import com.home766.dao.AppointmentDao;
import com.home766.entity.Appointment;
import com.home766.util.StringUtil;
import net.biz.Page;
import net.biz.Pageable;
import net.biz.dao.NativeBaseDao;
import net.biz.dao.impl.BaseDaoImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

@Repository("appointmentDaoImpl")
public class AppointmentDaoImpl extends BaseDaoImpl<Appointment,Long> implements AppointmentDao{
	@Autowired
	private NativeBaseDao nativeBaseDao;
	@Override
	public Page<Appointment> findList(Appointment appointment, Pageable pageable, String properties) {
		// TODO Auto-generated method stub
		String sql = " select appm.id as id,appm.aname as a_Name,appm.phone as phone,appm.measure as measure,appm.appointment as appointment,appm.handle as handle"
				+ ",appm.with_single as with_Single,sp.shops_name as shops_Name,sp.id as shops_Id from 766_appointment appm left join 766_shops sp on sp.id=appm.shops_id"
				+ " where 1=1 ";
		Map<String,Object> tempMap = new HashMap<String, Object>();
		if(StringUtil.isNotEmpty(properties)){
			sql+=" order by "+properties;
		}else{
			sql+=" order by appm.create_date desc";
		}
		return nativeBaseDao.findPage(sql,tempMap,pageable,Appointment.class);
	}
}
